<template>
  <!-- 虚拟帐号信息 -->
  <div
    class="item-block item-block2">
    <div class="title">虚拟帐号信息</div>
    <div v-for="(item,index) in detailAll.detail.item" :key="index">
      <div v-if="item.list && item.list.length>0" v-for="(item_vo,i) in item.list" :key="i">
        <div class="line-con">
          <div class="label">商品名称：</div>
          <div class="line-detail">{{item_vo.title}}</div>
        </div>
        <div>
          <div v-for="(msg,j) in item_vo.message" :key="j">
            <div class="line-con" v-if="msg.account">
              <div class="label">账号：</div>
              <div class="line-detail">
                <p v-html="msg.account"></p>
                <van-button round :hairline="false" class="copy" @click="copyClick(msg.account,$event)">复制</van-button>
              </div>
            </div>
            <div class="line-con" v-if="msg.pwd">
              <div class="label">密码：</div>
              <div class="line-detail" @click="goCouponCode(msg.pwd)">
                {{msg.pwd}}
                <van-button round :hairline="false" class="copy" @click="copyClick(msg.pwd,$event)">复制</van-button>
              </div>
            </div>
            <div class="line-con" v-if="msg.msg">
              <div class="label">其他：</div>
              <div class="line-detail">{{msg.msg}}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { openPage } from '@/utils/utils'
export default Vue.extend({
  props: {
    /* itemVirtualData: {
      type: Object,
      default: () => {
        return {}
      }
    }, */
    detailAll: {
      type: Object,
      default: () => {
        return {}
      }
    },
    dzData: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  methods: {
    goCouponCode(url) {
      var rx = /^https?:\/\//i
      if (rx.test(url)) {
        openPage(url)
      }
    },
    // 复制
    copyClick(text, e) {
      // TODO 微分销复制与小程序差别
        wx.setClipboardData({
          data: text,
          success (res) {
            wx.getClipboardData({
              success(res) {
                wx.showToast({
                  title: '复制成功',
                  icon: 'none',
                });
              }
            })
          }
        })
    }
  }
})
</script>

<style lang="scss">
@import "src/styles/order/detail";
</style>